ref(search): Add EAP API attribute visibility checks#116091
ref(search): Add EAP API attribute visibility checks#116091nsdeschenes wants to merge 13 commits into
Conversation
Add a shared helper for hiding internal Sentry convention attributes from API surfaces and let SearchResolver track attributes hidden by API visibility configuration. This keeps default resolver behavior unchanged unless an API caller opts into visibility enforcement.
The `as ATTRIBUTE_METADATA` pattern tells mypy this is an intentional re-export, fixing the attr-defined errors in tests that access it via `eap_utils.ATTRIBUTE_METADATA`.
|
|
||
| if column_definition: | ||
| if self.config.api_attribute_visibility_item_type is not None: | ||
| from sentry.search.eap.utils import can_expose_attribute_to_api |
There was a problem hiding this comment.
Any specific reason why we import this here and not at the top? Unless it otherwise leads to a circular import, I think we should move it to the top
There was a problem hiding this comment.
i tried this out, seems to have broken many things 😬
adrianviquez
left a comment
There was a problem hiding this comment.
Couple of comments, lmk what you think and can take a 2nd look!
The candidates set already prevents duplicates since we check `replacement not in candidates` before adding to pending.
Reverts the import move to avoid a circular import risk between resolver and utils modules.
When public_alias_override is set (e.g. equation resolution), the column_definition.public_alias becomes a synthetic label like "equation|…" which can_expose_attribute_to_api cannot evaluate against conventions, prefixes, or mappings.
Update EAP attribute visibility tests to exercise real sentry_conventions metadata instead of mocked convention metadata. Keep alias and replacement edge-case coverage while pointing those mappings at real internal DSC attributes. Co-Authored-By: Codex <noreply@openai.com>
Apply API attribute visibility while resolving selected attributes instead of storing hidden attribute names on the SearchResolver instance. Keep the API visibility config as the switch for this behavior and add coverage for hidden internal attributes and the include-internal override. Co-Authored-By: Codex <noreply@openai.com>
Apply API attribute visibility filtering to aggregate and equation operands so hidden attributes cannot be embedded in resolved RPC columns. Reject orderby fallback resolution when the selected column was filtered out for API visibility. Co-Authored-By: GPT-5 Codex <codex@openai.com>
Reject API-hidden attributes when resolving EAP WHERE terms, HAVING aggregate terms, and nested query combinator filters. This keeps api_attribute_visibility_item_type from exposing internal attributes through filter-only query paths. Co-Authored-By: Codex <noreply@openai.com>
Reject API-hidden attributes when resolving required EAP attributes. This prevents timeseries group_by requests from silently dropping hidden fields and becoming ungrouped aggregate queries. Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 661211e. Configure here.
| column | ||
| if column in self.definitions.contexts or column in self.definitions.columns | ||
| else resolved_attribute.internal_name | ||
| ) |
There was a problem hiding this comment.
Virtual context skips storage visibility
Medium Severity
API attribute visibility checks in _should_hide_api_attribute use the virtual context key, not the underlying storage attribute after remapping. This allows attributes intended to be hidden to be exposed in queries, particularly for timeseries, group-bys, and order-bys, as the check passes on the virtual key while the query uses the unhidden storage key.
Reviewed by Cursor Bugbot for commit 661211e. Configure here.


The goal of this PR is to lie down the foundational work of removing/hiding internal attributes from non-staff/non-super-user requests.
To determine if an attribute should be hidden or not, we pull that information from the Sentry conventions package from the
visibilityfield from attribute metadata.These changes are limited to the eap search resolver, as such this PR does not doing any enforcement of these attributes, that will come in follow up PRs. As well, this PR adds in some tests.